<?php

namespace App\Admin\Extensions\Tools;

use Encore\Admin\Grid\Tools\BatchAction;

/**
 *角色列表view层组件逻辑.
 */
class PlayerBanAction extends BatchAction
{
    /**
     * [script js代码].
     *
     * @Author   王文凡
     * @DateTime 2018-03-01
     *
     * @version  1.0
     *
     * @return [type] [description]
     */
    public function script()
    {
        return <<<EOT

    $('#reservationtime').datetimepicker({
        "format": "YYYY-MM-DD HH:mm:ss",
        "locale": "zh-CN"
    });

   $("#forbid-submit").on('click', function() {
        var cause = $("input[name='cause']").val(),
            exp_time = $("input[name='exp_time']").val();
        var param = {
            type: 'post',
            url: '{$this->resource}/forbid',
            data: {
                _token: LA.token,
                ids: selectedRows(),
                serverid: getPar('serverid'),
                cause: cause,
                exp_time: exp_time
            },
            success: function(data) {
                $.pjax.reload('#pjax-container');
                $(".close").click();
                toastr.success(data.message);
            }
        };
        ajaxHttp(param);
    });


$('{$this->getElementClass()}').on('click', function() {
    var playerIds = selectedRows();
    if(playerIds == ''){
        swal("请先选择角色");return;
    }
      //封角色
      $('#forbid-modal').modal();
      return false;
});

EOT;
    }
}
